﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Icst.Leaflike.Data;


namespace Icst.Leaflike.Web.category
{
    public partial class _default : pagebase
    {
        protected IEnumerable<tree_search_bycategoryResult> _categories = null;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string strphylum = this.Para("phylum");
                string strclassid = this.Para("classid");
                string strfamily = this.Para("family");
                string strgenus = this.Para("genus");
                string keyword = this.Para("keyword");

                int totalCount = 0;
                _categories = Category.Instance.Search(strphylum, strclassid, strfamily, strgenus, keyword, this.ParaInt("page", 1), this.ParaInt("sort"), 10, out totalCount);
                paginator.RecordCount = totalCount;
                paginator.Visible = totalCount > 0;

                phylumCascade.ClientState = strphylum;
                phylum.SelectedValue = strphylum;

                classidCascade.ClientState = strclassid;
                classid.SelectedValue = strclassid;

                familyCascade.ClientState = strfamily;
                family.SelectedValue = strfamily;

                genusCascade.ClientState = strgenus;
                genus.SelectedValue = strgenus;

                txtSearch.Text = keyword;
            }
        }
    }
}
